<?php
include '../newlib.php';
include '../lib/AppScope.pre.php';

$theUser = $app->theUser;

$id = $_REQUEST['id'];

$stm = $tmpConnection->prepare("select * from narrowbase.schema where artikel=:id");
$stm->execute(array('id' => $id));
$rs = $stm->fetch(PDO::FETCH_ASSOC);
if (!$rs) {
	$todayString = date("Ymd");
	$sql = "insert into narrowbase.schema (artikel, van, ma, di, wo, do, vr, za, zo) values (:id, :todayString,1,1,1,1,1,1,1)";
	$stm = $tmpConnection->prepare($sql);
	$stm->execute(array( ':id' => $id, ':todayString' => $todayString));
	$stm = $tmpConnection->prepare("select * from narrowbase.schema where artikel=:id");
	$stm->execute(array( ':id' => $id));
	$rs = $stm->fetch(PDO::FETCH_ASSOC);
}
header("Location: schema.php?id=" . $rs['schemaid'] . "&new=true");
?>